import java.util.StringTokenizer;


class P10926_39643 {

	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString()).trim();
	}

	
	public static void main(String[] args) {
		
		while (true) {
			int n = Integer.parseInt(readLn());
			
			if (n == 0) break;
			
			process(n);
			
		}
		
	}


	private static void process(int n) {
		
		Node10926[] graph = new Node10926[n]; 
		
		for (int k = 0; k < n; k++) {
			StringTokenizer st = new StringTokenizer(readLn());
			
			int d = Integer.parseInt(st.nextToken());
			
			graph[k] = new Node10926();
			
			graph[k].id = k;
			graph[k].directDependencies = new int[d];
			
			for (int j = 0; j < d; j++) {
				graph[k].directDependencies[j] = Integer.parseInt(st.nextToken()) - 1;
			}
			
		}
		
		int[] d = new int[n];
		
		for (int k = 0; k < n; k++) {

			calculate(graph[k], graph);
			
			int count = 0;

			for (int j = 0; j < n; j++) {
				if (graph[j].visited) count++;
				graph[j].visited = false;
			}
			
			d[k] = count - 1;
			
		}
		
		int max = Integer.MIN_VALUE;
		int id = -1;
		
		for (int k = 0; k < n; k++) {
//			System.out.println((k + 1) + ": " + d[k]);
			
			if (max < d[k]) {
				max = d[k];
				id = k;
			}
		}
		
//		System.out.println(max);
		
		System.out.println((id + 1));
		
	}


	private static void calculate(Node10926 node, Node10926[] graph) {
		
		if (node.visited) return;
			
		for (int k = 0; k < node.directDependencies.length; k++) {
			calculate(graph[node.directDependencies[k]], graph);
		}
		
		node.visited = true;
	}
	
}

class Node10926 {

	boolean visited = false;
	
	int id;
	
	int[] directDependencies;
	
}